cmake_minimum_required(VERSION 2.6)
project(gl)

### Common
#set(CMAKE_USE_RELATIVE_PATHS true)
add_definitions(-DNDEBUG -Wall -Wextra -O2 -pipe)
include_directories(.)
file (GLOB sources
	./gl/*.h
	./gl/*.cpp
	./math/*.h
	./math/*.cpp
	./utils/*.h
	./utils/*.cpp
)
add_custom_target(tags ALL
	COMMAND ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . 
	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

### Exercise 4
file (GLOB sources4
	./exercises/04-ProceduralTextures/*.h
	./exercises/04-ProceduralTextures/*.cpp
)
add_executable(04-ProceduralTextures ${sources} ${sources4})
target_link_libraries(04-ProceduralTextures GL GLU GLEW glut)
set_target_properties(04-ProceduralTextures
	PROPERTIES RUNTIME_OUTPUT_DIRECTORY "04-ProceduralTextures"
)
add_custom_command(TARGET 04-ProceduralTextures POST_BUILD
	COMMAND ln -sfT "${CMAKE_SOURCE_DIR}/../data" "./data"
	COMMAND ln -sfT "${CMAKE_SOURCE_DIR}/exercises/04-ProceduralTextures/procedural.fs" "./procedural.fs"
	COMMAND ln -sfT "${CMAKE_SOURCE_DIR}/exercises/04-ProceduralTextures/procedural.vs" "./procedural.vs"
	WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/04-ProceduralTextures"
)

### Exercise 5
file (GLOB sources5
	./exercises/05-Terrain/*.h
	./exercises/05-Terrain/*.cpp
)
add_executable(05-Terrain ${sources} ${sources5})
target_link_libraries(05-Terrain GL GLU GLEW glut)
set_target_properties(05-Terrain
	PROPERTIES RUNTIME_OUTPUT_DIRECTORY "05-Terrain"
)
add_custom_command(TARGET 05-Terrain POST_BUILD
	COMMAND ln -sfT "${CMAKE_SOURCE_DIR}/../data" "./data"
	COMMAND ln -sfT "${CMAKE_SOURCE_DIR}/exercises/05-Terrain/procedural.fs" "./procedural.fs"
	COMMAND ln -sfT "${CMAKE_SOURCE_DIR}/exercises/05-Terrain/procedural.vs" "./procedural.vs"
	COMMAND ln -sfT "${CMAKE_SOURCE_DIR}/exercises/05-Terrain/terrain.fs" "./terrain.fs"
	COMMAND ln -sfT "${CMAKE_SOURCE_DIR}/exercises/05-Terrain/terrain.vs" "./terrain.vs"
	# MERDE! COMMAND find ${CMAKE_SOURCE_DIR}/exercises/05-Terrain \\\( -iname '*.fs' -o -iname '*.vs' \\\) -exec ln -sft . '{}' \;
	WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/05-Terrain"
)

### Exercise 6
file (GLOB sources6
	./exercises/06-Bridge/*.h
	./exercises/06-Bridge/*.cpp
)
add_executable(06-Bridge ${sources} ${sources6})
target_link_libraries(06-Bridge GL GLU GLEW glut)
set_target_properties(06-Bridge
	PROPERTIES RUNTIME_OUTPUT_DIRECTORY "06-Bridge"
	WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/06-Bridge"
)
